<% layout('/layouts/default.html', {title: '结算管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa fa-list-alt"></i> ${text('结算管理')}
			</div>
			<div class="box-tools pull-right">
<!-- 				<% if(hasPermi('settlementapply:settlementApply:edit')){ %> -->
<!-- 					<a href="${ctx}/settlementapply/settlementApply/form" class="btn btn-default btnTool" title="${text('新增结算申请')}"><i class="fa fa-plus"></i> ${text('新增')}</a> -->
<!-- 				<% } %> -->
			</div>
		</div>
		<div class="box-body">
			<#form:form id="searchForm" model="${settlementApply}" action="${ctx}/settlementapply/settlementApply/listData" method="post" class="form-inline"
					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
				<div class="form-group">
					<label class="control-label">${text('申请方')}：</label>
					<div class="control-inline">
						<#form:input path="whatsoever" maxlength="30" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('姓名')}：</label>
					<div class="control-inline">
						<#form:input path="name" maxlength="30" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('申请状态')}：</label>
					<div class="control-inline">
						<#form:select path="settlementApplyState" dictType="settlement_apply_state" blankOption="true" class="width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('申请时间')}：</label>
                    <div class="control-inline" >
                            <#form:input path="createDate_gte" readonly="true" class="form-control" style="background: #fff; width: 150px;"
                            placeholder="开始时间" dataFormat="date" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:true});"/>
                        <span class="">&nbsp;——&nbsp;</span>
                    </div>
                    <div class="control-inline" >
                            <#form:input path="createDate_lte" readonly="true" class="form-control" style="background: #fff; width: 150px;"
                            placeholder="结束时间"  dataFormat="date" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'#F{$dp.$D(\\'createDate_gte\\', {d:1})||\\'%y-%M-%d\\'}',isShowClear:true});"/>
                    </div>
				</div>
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
					<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
				</div>
			</#form:form>
			<table id="dataGrid"></table>
			<div id="dataGridPage"></div>
		</div>
	</div>
</div>
<% } %>
<script>
// 初始化DataGrid对象
$('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	columnModel: [
		{header:'${text('渠道')}', name:'channel', index:'a.channel', width:100, align:"center", frozen:true},
		{header:'${text('申请方')}', name:'whatsoever', index:'a.whatsoever', width:180, align:"center"},
		{header:'${text('姓名')}', name:'name', index:'a.name', width:100, align:"center"},
		{header:'${text('联系方式')}', name:'contact', index:'a.contact', width:110, align:"center"},
		{header:'${text('结算概览')}', name:'settlementOverview', index:'a.settlement_overview', width:300, align:"center"},
		{header:'${text('结算金额')}', name:'settlementAmount', index:'a.settlement_amount', width:100, align:"center", formatter: function(val, obj, row, act){
			return js.formatNumber(val, 2, false, ''); // 数值类型格式化 (原始数值, 小数位数, 是否千分位, 默认值，金额情况下设置0.00);
		}},
		{header:'${text('场馆地址')}', name:'address', index:'a.address', width:250, align:"center"},
		{header:'${text('申请状态')}', name:'settlementApplyState', index:'a.settlement_apply_state', width:100, align:"center", formatter: function(val, obj, row, act){
			var actions = [];
			if(row.settlementApplyState == 1){
				actions.push('<div style="color:#fff;margin-top:15px;width:60%;height:30px;line-height:30px;text-align:center;background:#81C784;margin-left:20%" title="${text("结算中")}">结算中</div>&nbsp;');
			} else if(row.settlementApplyState == 2){
				actions.push('<div style="color:#fff;margin-top:15px;width:60%;height:30px;line-height:30px;text-align:center;background:#66BB6A;margin-left:20%" title="${text("已结算")}">已结算</div>&nbsp;');
			}
			return actions.join('');
		}},
		{header:'${text('操作')}', name:'actions', width:180, sortable:false, align:"center", title:false, formatter: function(val, obj, row, act){
			var actions = [];
			<% if(hasPermi('settlementapply:settlementApply:edit')){ %>
				actions.push('<a href="${ctx}/settlementapply/settlementApply/details?id='+row.id+'" class="btn btnList btn-operation" title="查看详情">${text("查看")}</a>&nbsp;');
				if(row.settlementApplyState == 1){
					actions.push('<a href="${ctx}/settlementapply/settlementApply/settlementCheck?settlementApplyId='+row.id+'&settlementAmount='+row.settlementAmount+'&submitter='+row.createBy+'" class="btn btnList btn-operation" title="审核">${text("审核")}</a>&nbsp;');
				}
			<% } %>
			return actions.join('');
		}}
	],
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});
</script>